package com.boboPlanet.dict.service.impl;

import com.boboPlanet.comm.exception.BusinessException;
import com.boboPlanet.dict.entity.dto.GenerateSqlDTO;
import com.boboPlanet.dict.enums.SqlOpeTypeEnum;
import com.boboPlanet.dict.mapper.GenerateSqlMapper;
import com.boboPlanet.dict.service.GenerateSqlService;
import com.boboPlanet.dict.utils.GenerateSqlUtil;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.Objects;

/**
 * @Description: TODO
 * @Author: mis_wu
 * @Date: 2023/7/23
 * @Company SQL
 **/
@Service
@Slf4j
public class GenerateSqlServiceImpl implements GenerateSqlService {

    @Resource
    private GenerateSqlMapper generateSqlMapper;

    @Override
    public String generateSqlByFiledList(GenerateSqlDTO sqlDTO) {
        GenerateSqlUtil.assertInsertSql(sqlDTO);
        return GenerateSqlUtil.buildSaveSqlOne(sqlDTO);
    }

    @Override
    @SneakyThrows
    public String generateSqlByFile(MultipartFile file, GenerateSqlDTO sql) {
        GenerateSqlUtil.assertInsertSql(sql);
        return GenerateSqlUtil.buildSaveSqlOne(file, sql);
    }
}
